package com.eascs.ant.common.dao;

import javax.inject.Inject;

import com.eascs.app.dao.PageResult;
import com.eascs.app.dao.mongo.MongoPageQuery;
import com.eascs.app.dao.mongo.MongoSession;

public abstract class ProxyMongoDao {

	@Inject
	protected MongoSession mongoSession;

	public MongoSession getMongoSession() {
		return mongoSession;
	}

	public void setMongoSession(MongoSession mongoSession) {
		this.mongoSession = mongoSession;
	}

	public <T> T findOne(Class<T> entityClass, String keyName, Object keyValue) {
		return mongoSession.findOne(entityClass, keyName, keyValue);
	}

	public <T> T findOne(Class<T> entityClass, Object id) {
		return mongoSession.findOne(entityClass, id);
	}

	public <T> T deleteOne(Class<T> entityClass, Object id) {
		return mongoSession.deleteOne(entityClass, id);
	}

	public <T> void update(T entity) {
		mongoSession.update(entity);
	}

	public <T> void insert(T entity) {
		mongoSession.insert(entity);
	}

	public <T> PageResult<T> findDataWithPage(MongoPageQuery<T> sqlPageQuery) {
		return mongoSession.findDataWithPage(sqlPageQuery);
	}

}
